<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('选择接收对象')"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: jasny-bootstrap-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m">
        <div class="form-group col-sm-12">
            <div class="col-sm-12">
                <div id="tree" class="ztree col-sm-6"></div>
                <div class="col-sm-6">
                    <div>
                        <label>是否选择上次发送通知接收人员：</label>
                        <label>
                            <div>
                                <p>否</p>
                                <input type="radio" checked="checked">
                                <span class="weui-icon-checked"></span>
                            </div>
                        </label>
                        <label>
                            <div>
                                <p>是</p>
                                <input type="radio">
                                <span class="weui-icon-checked"></span>
                            </div>
                        </label>
                    </div>
                    <input id="addresseeName" name="addresseeName" type="hidden" required>
                    <textarea id="realName" class="col-sm-12" rows="26" type="text" style="margin-right: 20px;"
                              placeholder="请选择接收对象" readonly required></textarea>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: jasny-bootstrap-js"/>
<script th:inline="javascript">
    $(function () {
        var url = ctx + "system/user/treeData";
        var options = {
            id: "tree",
            url: url,
            check: {enable: true},
            expandLevel: 1,
            onCheck: onCheck
        };
        $.tree.init(options);
    });

    function onCheck() {
        $('input[name="addresseeName"]').val(getChecked('id'));
        $('#realName').val(getChecked('name'));
    }

    function getChecked(column) {
        var nodes = $._tree.getCheckedNodes(true);
        return $.map(nodes, function (row) {
            if (!row.isParent) {
                return row[column]
            }
        }).join();
    }

    function submitHandler() {
        window.parent.setName($('input[name="addresseeName"]').val(),$('#realName').val());
        $.modal.close();
    }
</script>
</body>
</html>
